<!--
 * @Author: xuhy 1727317079@qq.com
 * @Date: 2022-09-04 09:48:48
 * @LastEditors: xuhy 1727317079@qq.com
 * @LastEditTime: 2022-09-05 11:16:10
 * @FilePath: \vue3_test\src\App.vue
 * @Description: 父组件
-->
<template>
  <h1>一个人的信息</h1>
  <h2>姓名: {{ person.name }}</h2>
  <h2>年龄: {{ person.age }}</h2>
  <h3>工作种类: {{ person.job.type }}</h3>
  <h3>工作薪水: {{ person.job.salary }}</h3>
  <h3>爱好: {{ person.hobby }}</h3>
  <h3>测试的数据: {{ person.job.a.b.c }}</h3>
  <button @click="changeInfo">修改个人信息</button>
</template>

<script>
import { reactive } from "vue";
export default {
  name: "App",
  setup() {
   
    let person = reactive({
      name: "张三",
      age: 18,
      job: {
        type: "前端工程师",
        salary: "30k",
        a: {
          b: {
            c: 666,
          },
        },
      },
      hobby:["抽烟", "喝酒", "打牌"]
    });

    function changeInfo() {
      person.name = "李四";
      person.age = 48;
      person.job.type = "UI设计师";
      person.job.salary = "60k";
      person.job.a.b.c = 999;
      person.hobby[0] = "学习";
    }
    // 返回一个对象(常用)
    return {
      person,
      changeInfo,
    };
  },
};
</script>
